package o;

import android.content.Context;
import android.text.TextUtils;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.application.pkgmanage.model.reserve.ReserveDbInfo;
import com.huawei.appgallery.foundation.application.pkgmanage.model.update.ApkUpgradeInfo;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol;
import com.huawei.appgallery.foundation.service.common.protocol.AppDetailActivityProtocol.Request;
import com.huawei.hms.support.hianalytics.HiAnalyticsConstant;
import o.dge.d;
import o.ewm.n;

public final class efa {
    public static void ˏ(Context context, ApkUpgradeInfo apkUpgradeInfo, String str, String str2) {
        String str3;
        if (context == null || apkUpgradeInfo == null || dof.ʽ(apkUpgradeInfo.ᐝ())) {
            String str4 = "GameRelaseNotification";
            StringBuilder append = new StringBuilder().append("showGameReleasedNotification failed, context = ").append(context).append(", apkUpgradeInfo = ");
            if (apkUpgradeInfo == null) {
                str3 = null;
            } else {
                str3 = apkUpgradeInfo.toString();
            }
            Logger.e(str4, append.append(str3).toString());
            return;
        }
        String ᐝ = apkUpgradeInfo.ᐝ();
        ReserveDbInfo ॱ = efg.ˋ().ॱ(ᐝ);
        if (!ˋ(ॱ, apkUpgradeInfo, ᐝ)) {
            Logger.e("GameRelaseNotification", "showGameReleasedNotification can not show notification." + ᐝ);
        } else if (eff.ˊ().ˏ().ˊ(ॱ.ॱˊ())) {
            Logger.ˎ("GameRelaseNotification", "showGameReleasedNotification, not reserved and gamebox support reserving game.");
        } else {
            str3 = ᐝ + "_" + ॱ.ˏॱ();
            int ˊ = efb.ॱ().ˊ(str3);
            if (ˊ < 1) {
                efb.ॱ().ˏ(str3, ˊ + 1);
                dko o_dko = new dko();
                str3 = context.getString(n.ʿʼ);
                str4 = context.getString(n.ˇॱ, new Object[]{apkUpgradeInfo.ˊ()});
                if (TextUtils.isEmpty(str2)) {
                    str2 = str3;
                } else {
                    Logger.ˎ("GameRelaseNotification", "use new noticeContent");
                }
                if (TextUtils.isEmpty(str)) {
                    str = str4;
                } else {
                    Logger.ˎ("GameRelaseNotification", "use new noticeTitle");
                }
                o_dko.ˋ(str);
                o_dko.ˊ(str2);
                cjo appDetailActivityProtocol = new AppDetailActivityProtocol();
                Request request = new Request();
                request.ˋ(drj.ॱ(ᐝ));
                request.ˋ(true);
                request.ॱॱ(ᐝ);
                appDetailActivityProtocol.ˏ(request);
                o_dko.ˊ(new cjm("appdetail.activity", appDetailActivityProtocol).ॱ(context));
                o_dko.ˏ(ᐝ.hashCode());
                int i = n.ʾॱ;
                dgh.onEvent(new d(context, i).ˏ(ᐝ + HiAnalyticsConstant.REPORT_VAL_SEPARATOR + UserSession.getInstance().getUserId()).ˋ());
                dkk.ˊ(ContentManager.getInstant().getContext(), o_dko).ˎ();
                Logger.ˎ("GameRelaseNotification", "showGameReleasedNotification: " + ᐝ);
                return;
            }
            Logger.ˎ("GameRelaseNotification", "showGameReleasedNotification, send notification size upto max, appTag = " + str3);
        }
    }

    private static boolean ˋ(ReserveDbInfo reserveDbInfo, ApkUpgradeInfo apkUpgradeInfo, String str) {
        return reserveDbInfo != null && dvt.ˏ().ˋ(str) == null && edp.ˏ().ˊ(str) == null;
    }
}
